<?php

namespace Addons\Wukong\Controller;

use Think\Hook;
use Home\Controller\AddonsController;


class WukongController extends AddonsController
{

    public function chatList()
    {
        $mid = is_login();
        if ($mid) {
            $this->assign('myInfo', query_user(array('avatar32', 'avatar64', 'space_url', 'nickname', 'uid', 'signature'), $mid));
            $this->assign('myInfo_json', json_encode(query_user(array('avatar32', 'avatar64', 'space_url', 'nickname', 'uid', 'signature'), $mid)));

            $friend_ids = D('Follow')->getMyFriends();

            $this->assign('friend_ids', implode(',', $friend_ids));

            if (count($friend_ids) > 100) {
                $friend_ids1 = array_chunk($friend_ids, 100);
                $friend_ids = $friend_ids1[0];
            }
            $friends = S('friends_list_' . $mid);
            if (empty($friends)) {
                $friends = array();
                foreach ($friend_ids as $v) {
                    $friends[$v] = query_user(array('avatar32', 'avatar64', 'space_url', 'nickname', 'uid', 'signature'), $v);
                }
                S('friends_list_' . $mid, $friends, 60 * 5);
            }
            $this->assign('friends', $friends);

        }
        $html = $this->fetch(T('Addons://Wukong@Wukong/list'));
        exit($html);

    }


}